<template>
  <basic-container>
    <avue-form ref="form"
               v-model="formData"
               :option="option"
               @submit="submit">
    </avue-form>
  </basic-container>
</template>
<script>
import { saveUpdateIntergral}
from '@/api/base/member/integralLog'
import {bannerDescribe} from '@/util/rej'
import {testPhone,testSpaceSize,isInteger0} from '@/util/util'
export default {
  data () {
    return {
      formData: {},
      option: {
        column: [
          {
            type: "input",
            label: "会员手机号",
            prop:"mobile",
            span: 12,
            display: true,
            required: true,
            rules: [
              {
                required: true,
                message: "会员手机号必须填写"
              },
              {
                required: true,
                validator:testPhone,
                trigger: 'blur'
              }
            ]
          },
          {
            type: "select",
            label: "操作类型",
            prop:"operationType",
            dicData: [
              {
                label: "增加",
                value: "1"
              },
              {
                label: "减少",
                value: "0"
              }
            ],
            span: 12,
            rules: [
                {
                  required: true,
                  message: "选择操作类型"
                }
            ],
          },
          {
            type: "input",
            label: "积分值",
            prop:"integral",
            span: 12,
            display: true,
            required: true,
            rules: [
              {
                required: true,
                message: "积分值必须填写",
                trigger: 'blur'
              },
              {
                validator:isInteger0,
                trigger: 'blur'
              }
            ]
          },
          {
            type: "textarea",
            label: "操作说明",
            prop:"content",
            span: 24,
            display: true,
            required: true,
            rules: [
              {
                required: true,
                validator:bannerDescribe,
                trigger: 'blur'
              }
            ]
          }
        ],
        labelPosition: "right",
        labelWidth: 100,
        gutter: 0,
        menuBtn: true,
        submitBtn: true,
        submitSize: "mini",
        submitText: "提交",
        emptyBtn: false,
        emptySize: "medium",
        emptyText: "清空",
        menuPosition: "center",
      }
    }
  },
  methods: {
    submit (formData,done) {
        saveUpdateIntergral(formData).then(res => {
          if (res.data.code == 200) {
              this.$message({
                  type: "success",
                  message: "提交成功"
              });
          //操作完成清空页面数据
            this.$refs.form.resetForm();
            this.$nextTick(()=>{
              this.$refs["form"].clearValidate();
            });
          } else {
            this.$message.error(res.data.message)
          }
        });
      done();
    }
  }
}
</script>
<style>
</style>